package com.example.demo.com.example.demo.controller;

import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Date;
// 遍历不同的row
public class demo3 {
    public static void main(String[] args) throws  Exception {
       InputStream fileOutputStream = new FileInputStream("d:\\我的第一个workboot1.xls");
        POIFSFileSystem poifsFileSystem = new POIFSFileSystem(fileOutputStream);
        HSSFWorkbook sheets = new HSSFWorkbook(poifsFileSystem);
        HSSFSheet sheetAt = sheets.getSheetAt(0);//第一个sheet页
        for ( int  i = 0; i < sheetAt.getLastRowNum();i++) {
            HSSFRow row = sheetAt.getRow(i);

//             遍历cell
            for (int j = 0; j < row.getLastCellNum(); j++) {
                HSSFCell cell = row.getCell(j);
                cell.getCellType();//单元格类型
                cell.getCellStyle();//样式
            }

        }
    }
}
